//
//  AudioPlayEngine.h
//  51-Tour
//
//  Created by xiang ying on 14-3-26.
//  Copyright (c) 2014年 xiang ying. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AVFoundation/AVAudioPlayer.h>
#import <AVFoundation/AVAudioSession.h>
#import <AudioToolbox/AudioToolbox.h>

@protocol AudioPlayEngineDelegate <NSObject>

- (void)audioPlayerDidFinishPlaying:(BOOL)flag;

- (void)audioPlayerBeginInterruption;

- (void)audioPlayerEndInterruption;

@end

@interface AudioPlayEngine : NSObject

@property(nonatomic,assign)id<AudioPlayEngineDelegate> _delegate;

+(instancetype)instance;

//开始播放，返回音频总时长
-(NSTimeInterval)playAudio:(NSData*)data;

//快进
-(BOOL)playAttime:(NSTimeInterval)time;

-(void)play;

//暂停播放
-(void)pausePlay;

//停止播放(yes  正常结束  no人为打断)
-(void)stopPlay:(BOOL)flag;

-(BOOL)hasData;

//获取当前播放时长
-(NSTimeInterval)getCurrentPlayTime;

-(BOOL)isPlaying;

@end
